﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace prova
{
    public partial class FrmCrearUsuari : Form
    {
        public FrmCrearUsuari()
        {
            InitializeComponent();
        }

        private void btnAceptar_Click(object sender, EventArgs e)
        {
            AlumneConversor acv = new AlumneConversor();
            int nMatr = 0;
            if (int.TryParse(txtBoxNmatricula.Text, out nMatr))
            {
                acv.Nmatricula = Convert.ToInt32(txtBoxNmatricula.Text);
                acv.Nom = txtBoxNom.Text;
                acv.Cognom = txtBoxCognom.Text;
                try
                {
                    acv.insert();
                    Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error al guardar, comprova que no existeixi la matrícula" + ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Dades incorrectes");
            }              
        }

        private void btnCancelar_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
